<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('焊接计划表列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
<!--                            <li>-->
<!--                                <label>焊接台编号：</label>-->
<!--                                <input type="text" name="sbId"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>存货编码：</label>-->
<!--                                <input type="text" name="productId"/>-->
<!--                            </li>-->

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('formId','bootstrap-table')"><i class="fa fa-search"></i>&nbsp;搜索</a>
<!--                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('formId','bootstrap-table')"><i class="fa fa-refresh"></i>&nbsp;重置</a>-->
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="plan:welding:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="plan:welding:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="plan:welding:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="plan:welding:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('plan:welding:edit')}]];
        var removeFlag = [[${@permission.hasPermi('plan:welding:remove')}]];
        var statusDatas = [[${@dict.getType('plan_datas')}]];
        var prefix = ctx + "plan/welding";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "焊接计划表",
                clickToSelect: true,//是否启用点击选中行
                uniqueId:"sbId",//表主键(用于修改和删除)
                sortName:"sbId",//必加排序 sortOrder: "asc"默认
                pageNumber: 1,
                pageSize: 15,
                pageList: [10, 25],
                columns: [
                    // {
                    //     halign: 'center',
                    //     align:'center',
                    //     checkbox: true
                    // },


                {
                    field: 'sbId',
                    title: '焊接台编号',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'productId',
                    title: '存货编码',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'number',
                    title: '焊接次数',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'planQuantity',
                    title: '计划数量',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'finishQuantity',
                    title: '完成数量',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'status',
                    title: '当前模式',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    sortable: true,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                    {
                        visible: editFlag == 'status' ? "0" : "1",
                        title: '是否切换',
                        align: 'center',
                        formatter: function (value, row, index) {
                            return lockdeTools(row);
                        }
                    },
                {
                    title: '操作',
                    halign: 'center',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.sbId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.sbId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        /* 锁定状态显示 */
        function lockdeTools(row) {
            if (row.status == "1") {
                return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="disable(\'' + row.sbId + '\')"></i> ';
            } else {
                return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="enable(\'' + row.sbId + '\')"></i> ';
            }
        }
        function disable(sbId) {
            $.modal.confirm("是否切换自动？", function () {
                $.operate.post(prefix + "/changeStatus", {"sbId": sbId, "status": "0"});
            })
        }
        function enable(sbId) {
            $.modal.confirm("是否切换手动？", function () {
                $.operate.post(prefix + "/changeStatus", {"sbId": sbId, "status": "1","productId":"","number":"0","planQuantity":"0","finishQuantity": "0"});
            })
        }

    </script>
</body>
</html>